#获取位姿的真值
# │  │  ├─ scene_gt.json 位姿的真值

import json,os,sys
sys.path.append(os.getcwd())
import numpy as np
from pose.load_pose import load_txt
from tqdm import tqdm
def main():
    folder = r'E:\pose\datasets\obj_ac\obj_000003\train_pbr\000001'
    length = len(os.listdir(f"{folder}/pose"))
    scene_gt = {}
    for i in tqdm(range(length)):
        pose = load_txt(f"{folder}/pose", i)
        cam_R_m2c = pose[:3,:3].flatten().tolist()
        cam_t_m2c = pose[:3,3].flatten().tolist()
        scene_gt[str(i)] = [{"cam_R_m2c": cam_R_m2c, 
                             "cam_t_m2c": cam_t_m2c, 
                             "obj_id": 1}]

    # Save scene_gt as a JSON file
    with open(f'{folder}/scene_gt.json', 'w') as f:
        json.dump(scene_gt, f)

if __name__ == "__main__":
    main()